One or more aspects relate, in general, to computer processing, and in particular to, predicting the direction of branches within instruction streams.
Computing environments often use instruction pipelining to improve instruction execution, by allowing a number of instructions to be executed in parallel. In particular, a pipeline has a plurality of processing stages and different instructions may be processing at different stages of the pipeline in parallel. With such processing, however, a conditional branch instruction may result in a pipeline stall if the processor waits until the condition that defines the direction of the branch (i.e., taken or not taken) is resolved before fetching a next instruction. Thus, a branch predictor may be used to attempt to guess whether a branch will be taken or not; i.e. the direction of the branch. This allows the processing to be speculatively executed in the direction that the code eventually proceeds when the branch direction is predicted accurately. The penalty for an incorrect prediction equals or slightly exceeds the penalty encountered for stalling at the branch until the outcome of the branch is known. However, the performance gain for correctly predicting the branch direction can be as great as a cycle count advantage that is of similar length to the pipeline stall.
Further, a branch predictor may also include branch target prediction, which attempts to guess a target of a taken branch before it is computed by decoding and executing the instruction itself.